﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace FormsAppT8
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            if (comboBox1.Text == "")
            {
                MessageBox.Show("请选择公司参数！", "提示信息");
            }
            else
            {
                int fogid = 1000;
                if (comboBox1.Text == "电工")
                {
                    fogid = 1000;
                }
                else if (comboBox1.Text == "日中")
                {
                    fogid = 1001;
                }
                else if (comboBox1.Text == "升乐")
                {
                    fogid = 1002;
                }
                string sql = "select top 10 a.BillDate,a.BillNo,a.BizPartnerId,b.BizPartnerName from salDispatchListMaster a,comBusinessPartner b where a.BizPartnerId=b.BizPartnerId and a.forgid='" + fogid + "' and a.billdate>=" + dateTimePicker1.Value.ToString("yyyyMMdd") + "  and a.billdate<=" + dateTimePicker2.Value.ToString("yyyyMMdd") + " and a.billno like '%" + textBox1.Text + "%' and b.BizPartnerName like '%" + textBox3.Text + "%'";
                dbconn db = new dbconn();

                db.databind(sql, "salDispatchListMaster", dataGridView1);
            }
        }

        private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int fogid = 1000;
            if (comboBox1.Text == "电工")
            {
                fogid = 1000;
            }
            else if (comboBox1.Text == "日中")
            {
                fogid = 1001;
            }
            else if (comboBox1.Text == "升乐")
            {
                fogid = 1002;
            }
            string x2 = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
            string x3 = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
            string x4 = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
            Form1 form = new Form1(fogid,x2,x3,x4);
            if (form.ShowDialog() == DialogResult.OK)
            {
                
            }
        }

        private void comboBox1_TextChanged(object sender, EventArgs e)
        {
            label6.Text = "公司：" + comboBox1.Text;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox3.Text = "";
        }
    }
}
